package echat.future.cn.echat.my.adapter;

import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
import android.view.View;

import java.util.List;

/**
 * Created by 86936 on 2018/7/14.
 *
 * @QQ 869360026
 */

public class SpacesItemDecoration extends RecyclerView.ItemDecoration {
    public Context context;
    private List groupEntities;
    int pading = 0;
    public SpacesItemDecoration(Context context, List data) {
        this.context = context;
        this.groupEntities = data;
        pading = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,1,context.getResources().getDisplayMetrics());
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        //左边第一个
        if(groupEntities.size() == 0){
            return;
        }
        if(parent.getChildAdapterPosition(view)%2 == 0){
            outRect.right = pading;
        }
        outRect.bottom = pading;
    }
}
